package org.misalen.web.database.repository.mysql;

import org.hibernate.Query;
import org.hibernate.Session;
import org.misalen.web.database.dao.mysql.impl.BaseMySqlDaoImpl;
import org.misalen.web.database.model.mysql.pro.ProAdvertOrderPayInfo;
import org.springframework.stereotype.Repository;

@Repository
public class ProAdvertOrderPayInfoRepository extends BaseMySqlDaoImpl<ProAdvertOrderPayInfo> {

	public ProAdvertOrderPayInfo getByOrderId(String out_trade_no) {
		
		return get("from ProAdvertOrderPayInfo where orderId=?0", new Object[]{out_trade_no});
	}

	public void deleteByOrderId(String orderId) {
		String sql = "delete from ProAdvertOrderPayInfo where orderId='" + orderId + "'";
		
		Session session = this.openSession();
		Query query = session.createQuery(sql);
		query.executeUpdate();
		closeSession(session);
	}

}